package designpattern.Composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @author cyt
 * @create 2020-07-20 13:17
 */
public class Collage extends OrganizationComponent {


    public Collage(String name, String des) {
        super(name, des);
    }

    /**
     * 存放专业
     */
    List<OrganizationComponent> list = new ArrayList<>();

    @Override
    public void print() {

        System.out.println("-----" + getName() + "-------");
        for (OrganizationComponent component : list) {
            component.print();
        }
    }

    @Override
    protected void add(OrganizationComponent organizationComponent) {
        list.add(organizationComponent);
    }

    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        list.remove(organizationComponent);
    }

    @Override
    public String toString() {
        return "Collage{" +
                "list=" + list +
                '}';
    }
}
